package com.hemaapp.yjnh.activity;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import com.hemaapp.hm_FrameWork.HemaNetTask;
import com.hemaapp.hm_FrameWork.result.HemaBaseResult;
import com.hemaapp.yjnh.BaseFragmentActivity;
import com.hemaapp.yjnh.R;
import com.hemaapp.yjnh.adapter.TabViewPagerAdapter;
import com.hemaapp.yjnh.fragment.BookOrderListFragment;

/**我的预约
 * @author ZhangGuiyou
 * Date: 2015-07-30 13:20
 *
 */
public class BookOrderListActivity extends BaseFragmentActivity {

	@Bind(R.id.title_left_btn)
	ImageButton titleLeftBtn;
	@Bind(R.id.title_right_btn)
	Button titleRightBtn;
	@Bind(R.id.title_text)
	TextView titleText;
	@Bind(R.id.layout_tab)
	TabLayout layoutTab;
	@Bind(R.id.viewpager)
	ViewPager viewpager;

	private BookOrderListFragment allFragment = new BookOrderListFragment();
	private BookOrderListFragment unConsumeFragment = new BookOrderListFragment();
	private BookOrderListFragment unCommentFragment = new BookOrderListFragment();
	private TabViewPagerAdapter pagerAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_custom_orders);
		ButterKnife.bind(this);
		super.onCreate(savedInstanceState);
		initDatas();
	}
	
	private void initDatas() {
        List<String> titles = new ArrayList<>();
        titles.add("全部");
        titles.add("待消费");
        titles.add("待评价");
        List<Fragment> fragments = new ArrayList<>();
        allFragment.setType("1");
        unConsumeFragment.setType("4");
        unCommentFragment.setType("5");
        fragments.add(allFragment);
        fragments.add(unConsumeFragment);
        fragments.add(unCommentFragment);
        pagerAdapter = new TabViewPagerAdapter(getSupportFragmentManager(), fragments, titles);
        viewpager.setAdapter(pagerAdapter);
        viewpager.setOffscreenPageLimit(5);
        layoutTab.setTabMode(TabLayout.MODE_FIXED);
        layoutTab.setupWithViewPager(viewpager);
        layoutTab.setTabsFromPagerAdapter(pagerAdapter);
	}

    @Override
    protected void callBeforeDataBack(HemaNetTask hemaNetTask) {

    }

    @Override
    protected void callAfterDataBack(HemaNetTask hemaNetTask) {

    }

    @Override
    protected void callBackForServerSuccess(HemaNetTask hemaNetTask, HemaBaseResult hemaBaseResult) {

    }

    @Override
    protected void callBackForServerFailed(HemaNetTask hemaNetTask, HemaBaseResult hemaBaseResult) {

    }

    @Override
    protected void callBackForGetDataFailed(HemaNetTask hemaNetTask, int i) {

    }

	@Override
	protected void findView() {
	}

	@Override
	protected void getExras() {
	}

	@Override
	protected void setListener() {
		titleText.setText("我的预约管理");
		titleRightBtn.setVisibility(View.GONE);
	}

    @OnClick({R.id.title_left_btn, R.id.title_right_btn})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.title_left_btn:
                finish();
                break;
            case R.id.title_right_btn:
                break;
        }
    }

//	/**取消预约，也就是申请退款
//	 * @param order
//	 */
//	public void cancelOrder(final Order order) {
//		String enable = order.getReturn_enable();
//		// 预约订单是否能退款 0否；1是
//		if (enable.equals("1")) {
//			HemaButtonDialog hbDialog = new HemaButtonDialog(mContext);
//			hbDialog.setText("确认取消订单吗？");
//			hbDialog.setLeftButtonText("取消");
//			hbDialog.setRightButtonText("确定");
//			hbDialog.setRightButtonTextColor(getResources().getColor(
//					R.color.theme_orange));
//			hbDialog.setButtonListener(new HemaButtonDialog.OnButtonListener() {
//
//				@Override
//				public void onRightButtonClick(HemaButtonDialog dialog) {
//					dialog.cancel();
//					if (user != null && order != null) {
//						getNetWorker().orderSaveoperate(user.getToken(),
//								order.getChildren().get(0).getId(), "3", "无", "无", "无", "无");
//					}
//				}
//
//				@Override
//				public void onLeftButtonClick(HemaButtonDialog dialog) {
//					dialog.cancel();
//				}
//			});
//		} else {
//			Dialog dialog2 = new Dialog(mContext, R.style.dialog);
//			View view = getLayoutInflater().inflate(
//					R.layout.dialog_refuse_aftersale, null);
//			TextView tv_phone = (TextView) view.findViewById(R.id.tv_phone);
//			final String number = getApplicationContext().getSysInitInfo()
//					.getSys_service_phone();
//			tv_phone.setText(number);
//			tv_phone.setOnClickListener(new OnClickListener() {
//
//				@Override
//				public void onClick(View v) {
//					Intent intent = new Intent(Intent.ACTION_CALL, Uri
//							.parse("tel:" + number));
//					startActivity(intent);
//				}
//			});
//			dialog2.setCancelable(true);
//			dialog2.setContentView(view);
//			dialog2.show();
//		}
//	}

}
